package vfrpt

class DataStatisticsController {
    def dynamicQueryService
    def dataStatistics(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList=[]
        def dataStatistics=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0

        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'dataStatistics'
            dataStatistics = dynamicQueryService.queryForList(params)
            if (dataStatistics.size() > 0) {
                tableHeadList = dataStatistics[0].keySet()
            }
        }
        def listQz=[]
        def listSi=[]
        def listVf=[]
        def listFc=[]
        def listPv=[]
        def listWg=[]
        def listTe=[]
        def type
        def orderQty
        def inQty
        def outQty
        def putInQty
        for(int i=0;i<dataStatistics.size();i++) {
            if (dataStatistics[i].TYPE=="qz"){
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listQz.add(orderQty)
                listQz.add(inQty)
                listQz.add(outQty)
                listQz.add(putInQty)
            }else if(dataStatistics[i].TYPE=="si"){
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listSi.add(orderQty)
                listSi.add(inQty)
                listSi.add(outQty)
                listSi.add(putInQty)
            }
            else if(dataStatistics[i].TYPE=="vf"){
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listVf.add(orderQty)
                listVf.add(inQty)
                listVf.add(outQty)
                listVf.add(putInQty)
            }
            else if(dataStatistics[i].TYPE=="pv"){
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listPv.add(orderQty)
                listPv.add(inQty)
                listPv.add(outQty)
                listPv.add(putInQty)
            }
            else if(dataStatistics[i].TYPE=="te"){
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listTe.add(orderQty)
                listTe.add(inQty)
                listTe.add(outQty)
                listTe.add(putInQty)
            }
            else if(dataStatistics[i].TYPE=="wg"){
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listWg.add(orderQty)
                listWg.add(inQty)
                listWg.add(outQty)
                listWg.add(putInQty)
            }else{
                orderQty = dataStatistics[i].order_qty
                inQty = dataStatistics[i].in_qty
                outQty = dataStatistics[i].out_qty
                putInQty = dataStatistics[i].putin_qty
                listFc.add(orderQty)
                listFc.add(inQty)
                listFc.add(outQty)
                listFc.add(putInQty)
            }
        }

        println(listPv)
        println(listWg)
        [startno:params.startno?:'',
         endno:params.endno?:'',
         pageSize:pageSize,
         totalCount: totalCount,
         pageSizeList: pageSizeList,
         tableHeadList:tableHeadList,
         dataStatistics:dataStatistics,
         startTime:params.startTime?:'',
         endTime:params.endTime?:'',
         BU:params.BU?:'',
         listQz:listQz,
         listSi:listSi,
         listVf:listVf,
         listFc:listFc,
         listPv:listPv,
         listWg:listWg,
         listTe:listTe
        ]
    }
}
